package com.olympus.hermes.controller;

import com.olympus.hermes.bean.dto.member.CreateMemberDTO;
import com.olympus.hermes.bean.dto.member.OutputMemberDTO;
import com.olympus.hermes.common.support.PageRequest;
import com.olympus.hermes.service.MemberService;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author Mickey
 * @since 2021/2/1
 */
@RestController
@RequestMapping("/member")
@AllArgsConstructor
public class MemberController {

    private final MemberService memberService;

    @PostMapping("/create")
    public void create(@RequestBody @Valid CreateMemberDTO createMember) {
        memberService.create(createMember);
    }

    @GetMapping("/list")
    public Page<OutputMemberDTO> list(PageRequest pageRequest) {
        return memberService.list(pageRequest);
    }
}
